package model;

import entity.ClassRoomBlock;
import entity.Mark;
import entity.Subject;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Noi
 */
public class ResultOfStudentTableModel extends AbstractTableModel {

    private ArrayList<Mark> alMark;
    private manager.Manager manager;
    
    public ResultOfStudentTableModel(ArrayList<Mark> alMark, manager.Manager manager) {
        this.alMark = alMark;
        this.manager = manager;
    }
    
    @Override
    public int getRowCount() {
        return this.alMark.size();
    }

    @Override
    public int getColumnCount() {
        return 5;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Mark mark = this.alMark.get(rowIndex);
        Subject subject = this.manager.getSubjectManager().getById(mark.getSubjectID());
        ClassRoomBlock block = this.manager.getClassRoomBlockManager().getById(subject.getClassRoomBlockID());
        
        switch(columnIndex) {
            case 0:
                return block.getClassRoomBlockName();
            case 1:
                return subject.getSubjectName();
            case 2:
                return mark.getFirstSemesterValue();
            case 3:
                return mark.getSecondSemesterValue();
            case 4: 
                return mark.getYearValue();
            default: 
                return null;
        }
    }

    @Override
    public String getColumnName(int column) {
        switch(column) {
            case 0:
                return "Khối Lớp";
            case 1:
                return "Tên Môn Học";
            case 2:
                return "Học Kì 1";
            case 3:
                return "Học Kì 2";
            case 4: 
                return "Cả Năm";
            default: 
                return null;
        }
    }
}
